#include <mmu.h>
#include <mach/memlayout.h>

#define REALLOC(x) (x - KERNBASE)

.text
.globl kern_entry
kern_entry:
    # reload temperate gdt (second time) to remap all physical memory
    # virtual_addr 0~4G=linear_addr&physical_addr -KERNBASE~4G-KERNBASE 
    

relocated:
    # the kernel stack region is from bootstack -- bootstacktop,
    # the kernel stack size is KSTACKSIZE (8KB)defined in memlayout.h
    ldr sp,=bootstacktop
	
    # now kernel stack is ready , call the first C function
    b kern_init

# should never get here
spin:
    b spin

.data
# There might be a alignment problem, as should be aligned to a page size
    .globl bootstack
bootstack:
    .space KSTACKSIZE
    .globl bootstacktop
bootstacktop:


